#ifndef FFLIST_H
#define FFLIST_H

#include <iostream>
#include <list>
#include <algorithm>
#include <iterator>


#include "FFrame.h"

//FF_BEGIN


template <class T> class FFList
{
private:
    std::list<T> m_list;
    
public:
    void addItem(T p_item)
    {
        m_list.push_back(p_item);
    }
    
    unsigned int count() const
    {
        return m_list.size();
    }
    
    T itemAtIndex(unsigned int p_index)
    {
        std::_List_iterator<T> v_iterator = m_list.begin();
        std::advance(v_iterator, p_index);

        return (*v_iterator);
    }
    
    bool contains(const T &p_value)
    {
        std::_List_iterator<T> v_iterator;
        v_iterator = std::find(m_list.begin(), m_list.end(), p_value);
        
        if (v_iterator != m_list.end())
        {
            return true;
        }
        
        return false;
    }
    
    int findIndex(const T &p_value)
    {
        std::_List_iterator<T> v_iterator;
        
        int v_count = 0;
        v_iterator = m_list.begin();
        while (v_iterator != m_list.end()) 
        {
            if (p_value == (*v_iterator))
            {
                return v_count;
            }
        }
        
        return -1;
    }
    
    std::_List_iterator<T> begin()
    {
        return m_list.begin();
    }
    
    std::_List_iterator<T> end()
    {
        return m_list.end();
    }
    
    void remove(const T &p_value)
    {
        m_list.remove(p_value);
    }
    
    void clear()
    {
        m_list.clear();
    }
};

//FF_END

#endif